// ----------------------------------------------------------------------------
// concurrent_unit_test.cpp
// ----------------------------------------------------------------------------
#include <fw/base/core/macros.h>
#if defined(FW_ENABLE_UNIT_TEST)
#include <fw/base/core/debugconsole.h>
#include <gtest/gtest.h>

#include <fw/base/concurrent/thread.h>
#include <fw/base/concurrent/mutex.h>

namespace
{
	fw::Mutex m("test");
	static int g_threadTestValue = -1;
	
	void TestThread0(fw::ThreadArg arg)
	{
		fw::MutexLocker l(m);
		FW_PRINTF("Enter thread function.\n");
		g_threadTestValue = 1;
	}
	

}

TEST(concurrent, thread_test0)
{
	g_threadTestValue = 0;
	fw::Thread threadTest;
	{
		fw::MutexLocker l(m);
		threadTest.Initialize("thread test", TestThread0, (fw::ThreadArg)0);
	}
	threadTest.Join();
	ASSERT_GE(fw::Thread::GetNumberOfProcessors(), 1);
	ASSERT_EQ(g_threadTestValue, 1);
}

TEST(concurrent, atomic_test0)
{
	
}

#endif // FW_ENABLE_UNIT_TEST

void CONCURRENT_UNIT_TEST()
{
}